package com.woniuxy.company5.controller;

import com.woniuxy.company5.dto.UserEmpDto;
import com.woniuxy.company5.entity.RepNew;
import com.woniuxy.company5.entity.UserEmp;
import com.woniuxy.company5.entity.UserPermission;

import com.woniuxy.company5.service.UserEmpService;
import com.woniuxy.company5.service.UserPermissionService;
import com.woniuxy.company5.util.Result;
import com.woniuxy.company5.vo.UserPermissionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("users")
public class LoginController {
    @Resource
    private UserEmpService userEmpService;
    @Resource
    private UserPermissionService userPermissionService;
    @PostMapping("login")
    public Result login(@RequestBody UserEmpDto userEmpDto){
        UserEmp userEmp = userEmpService.selectByAccAndPwd(userEmpDto);
        if (userEmp != null) {
            List<UserPermissionVo> permissionVos = userPermissionService.selectMenu(1);
            return Result.ok().data("menuList",permissionVos).data("userdata",userEmp);
        }else {
            return Result.error();
        }
    }

}
